<?php
/**
 * Created by PhpStorm.
 * User: THUNDEROBOT
 * Date: 2021/1/11
 * Time: 15:29
 */

namespace app\admin\controller;

use app\admin\model\Score;
use think\Controller;
use think\Request;

class Scores extends Controller
{
    public function index(){
        $scoreModel = new Score();
        $scoreList = $scoreModel->score();
//         dump($questionList->toArray());
        $emptyHtml = '<tr><td align="center" colspan="5">暂无任何数据</td></tr>';
        $this->assign("emptyHtml",$emptyHtml);
        $this->assign("scoreList",$scoreList);
        return $this->fetch();
    }
    //编辑学生分数
    public function editscore(){
        if(Request::instance()->isGet()){
            $id = Request::instance()->get("id");

            $userModel = new Score();
            $Data = $userModel->editscore($id);
            $this->assign("id",$Data);
            $this->assign("s_name",$Data);
            $this->assign("s_score",$Data);
        }
        return $this->fetch("editscore");
    }

    //提交编辑学生分数
    public function doEdit(){
        if(Request::instance()->isPost()){
            $userDate = Request::instance()->post();
//            dump($userDate);
            $userModel = new Score();
            $re = $userModel->doEdit($userDate);
            if($re){
                $this->success("修改成功",'admin/scores/index');
            }else{
                $this->error("修改失败");
            }
        }
    }


}